package com.irdstudio.efp.edoc.service.impl;

import java.util.List;
import java.util.Objects;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.irdstudio.basic.framework.core.base.FrameworkService;
import com.irdstudio.efp.edoc.service.facade.UpLoadFileTempService;
import com.irdstudio.efp.edoc.service.dao.UpLoadFileTempDao;
import com.irdstudio.efp.edoc.service.domain.UpLoadFileTemp;
import com.irdstudio.efp.edoc.service.bo.UpLoadFileTempVO;


/**
 * Service Impl: 上传影像信息临时表服务实现
 * @author ligm
 * @date 2019-06-03 
 */
@Service("upLoadFileTempService")
public class UpLoadFileTempServiceImpl implements UpLoadFileTempService, FrameworkService {
	
	private static Logger logger = LoggerFactory.getLogger(UpLoadFileTempServiceImpl.class);

	@Autowired
	private UpLoadFileTempDao upLoadFileTempDao;

   	/**
	 * 新增数据 
     * @param inUpLoadFileTempVo
     * @return 
	 */
	public int insertUpLoadFileTemp(UpLoadFileTempVO inUpLoadFileTempVo) {
		logger.debug("当前新增数据为:"+ inUpLoadFileTempVo.toString());
		int num = 0;
		try {
			UpLoadFileTemp upLoadFileTemp = new UpLoadFileTemp();
			beanCopy(inUpLoadFileTempVo, upLoadFileTemp);
			num = upLoadFileTempDao.insertUpLoadFileTemp(upLoadFileTemp);
		} catch (Exception e) {
			logger.error("新增数据发生异常!", e);
			num = -1;
		}
		logger.debug("当前新增数据条数为:"+ num);
		return num;
	}

    /**
	 * 根据主键删除信息 
	 * @param inUpLoadFileTempVo
 	 * @return
	 */
	public int deleteByPk(UpLoadFileTempVO inUpLoadFileTempVo) {
		logger.debug("当前删除数据条件为:"+ inUpLoadFileTempVo);
		int num = 0;
		try {
			UpLoadFileTemp upLoadFileTemp = new UpLoadFileTemp();
			beanCopy(inUpLoadFileTempVo, upLoadFileTemp);
			num = upLoadFileTempDao.deleteByPk(upLoadFileTemp);
		} catch (Exception e) {
			logger.error("删除数据发生异常!", e);
			num = -1;
		}
		logger.debug("根据条件:"+ inUpLoadFileTempVo +"删除的数据条数为"+ num);
		return num;
	}


    /**
	 * 根据主键更新信息 
	 * @param inUpLoadFileTempVo
	 * @return 
	 */  
	public int updateByPk(UpLoadFileTempVO inUpLoadFileTempVo) {
		logger.debug("当前修改数据为:"+ inUpLoadFileTempVo.toString());
		int num = 0;
		try {
			UpLoadFileTemp upLoadFileTemp = new UpLoadFileTemp();
			beanCopy(inUpLoadFileTempVo, upLoadFileTemp);
			num = upLoadFileTempDao.updateByPk(upLoadFileTemp);
		} catch (Exception e) {
			logger.error("修改数据发生异常!", e);
			num = -1;
		}
		logger.debug("根据条件:"+ inUpLoadFileTempVo +"修改的数据条数为"+ num);
		return num;
	}
	
    /**
	 * 根据主键查询详情 
	 * @param upLoadFileTemp
	 * @return 
	 */
	public UpLoadFileTempVO queryByPk(UpLoadFileTempVO inUpLoadFileTempVo) {
		
		logger.debug("当前查询参数信息为:"+ inUpLoadFileTempVo);
		try {
			UpLoadFileTemp queryUpLoadFileTemp = new UpLoadFileTemp();
			beanCopy(inUpLoadFileTempVo, queryUpLoadFileTemp);
			UpLoadFileTemp queryRslUpLoadFileTemp = upLoadFileTempDao.queryByPk(queryUpLoadFileTemp);
			if (Objects.nonNull(queryRslUpLoadFileTemp)) {
				UpLoadFileTempVO outUpLoadFileTempVo = beanCopy(queryRslUpLoadFileTemp, new UpLoadFileTempVO());
				logger.debug("当前查询结果为:"+ outUpLoadFileTempVo.toString());
				return outUpLoadFileTempVo;
			} else {
				logger.debug("当前查询结果为空!");
			}
		} catch (Exception e) {
			logger.error("查询数据发生异常!", e);
		}
		return null;
	}


    /**
	 * 一级数据权限 
	 * @param upLoadFileTemp
	 * @return 
	 */	
	@SuppressWarnings("unchecked")
	public List<UpLoadFileTempVO> queryAllByLevelOne(UpLoadFileTempVO upLoadFileTempVo) {
		logger.debug("查看当前用户对应的数据信息的参数信息为:");
		List<UpLoadFileTempVO> list = null;
		try {
			List<UpLoadFileTemp> upLoadFileTemps = upLoadFileTempDao.queryAllByLevelOneByPage(upLoadFileTempVo);
			logger.debug("查看当前用户对应的数据信息的结果集数量为:"+ upLoadFileTemps.size());
			pageSet(upLoadFileTemps, upLoadFileTempVo);
			list = (List<UpLoadFileTempVO>) beansCopy(upLoadFileTemps, UpLoadFileTempVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}
		
		return list;
	
	}


    /**
	 * 二级数据权限 
	 * @param upLoadFileTemp
	 * @return 
	 */
	@SuppressWarnings("unchecked")
	public List<UpLoadFileTempVO> queryAllByLevelTwo(UpLoadFileTempVO upLoadFileTempVo) {
		logger.debug("查看当前用户及所属机构对应的数据信息的参数信息为:");
		List<UpLoadFileTemp> upLoadFileTemps = upLoadFileTempDao.queryAllByLevelTwoByPage(upLoadFileTempVo);
		logger.debug("查看当前用户及所属机构对应的数据信息的结果集数量为:"+upLoadFileTemps.size());
		List<UpLoadFileTempVO> list = null;
		try {
			pageSet(upLoadFileTemps, upLoadFileTempVo);
			list = (List<UpLoadFileTempVO>) beansCopy(upLoadFileTemps, UpLoadFileTempVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}
		
		return list;
	
	}


    /**
	 * 三级数据权限 
	 * @param upLoadFileTemp
	 * @return 
	 */
	@SuppressWarnings("unchecked")
	public List<UpLoadFileTempVO> queryAllByLevelThree(UpLoadFileTempVO upLoadFileTempVo) {
		logger.debug("查看当前用户所在机构及下属机构对应的数据信息的参数信息为:");
		List<UpLoadFileTemp> upLoadFileTemps = upLoadFileTempDao.queryAllByLevelThreeByPage(upLoadFileTempVo);
		logger.debug("查看当前用户所在机构及下属机构对应的数据信息的结果集数量为:"+ upLoadFileTemps.size());
		List<UpLoadFileTempVO> list = null;
		try {
			pageSet(upLoadFileTemps, upLoadFileTempVo);
			list = (List<UpLoadFileTempVO>) beansCopy(upLoadFileTemps, UpLoadFileTempVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}
		
		return list;
	}

    /**
	 * 四级数据权限  
	 * @param upLoadFileTemp
	 * @return 
	 */
	@SuppressWarnings("unchecked")
	public List<UpLoadFileTempVO> queryAllByLevelFour(UpLoadFileTempVO upLoadFileTempVo) {
		logger.debug("【预留，便于后续自定义 】信息的参数信息为:");
		List<UpLoadFileTemp> upLoadFileTemps = upLoadFileTempDao.queryAllByLevelFourByPage(upLoadFileTempVo);
		logger.debug("【预留，便于后续自定义 】信息的结果集数量为:"+ upLoadFileTemps.size());
		List<UpLoadFileTempVO> list = null;
		try {
			pageSet(upLoadFileTemps, upLoadFileTempVo);
			list = (List<UpLoadFileTempVO>) beansCopy(upLoadFileTemps, UpLoadFileTempVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}
		
		return list;
	}

    /**
	 * 五级数据权限  
	 * @param upLoadFileTemp
	 * @return 
	 */
	@SuppressWarnings("unchecked")
	public List<UpLoadFileTempVO> queryAllByLevelFive(UpLoadFileTempVO upLoadFileTempVo) {
		logger.debug("【预留，便于后续自定义 】信息的参数信息为:");
		List<UpLoadFileTemp> upLoadFileTemps = upLoadFileTempDao.queryAllByLevelFiveByPage(upLoadFileTempVo);
		logger.debug("【预留，便于后续自定义 】信息的结果集数量为:"+ upLoadFileTemps.size());
		List<UpLoadFileTempVO> list = null;
		try {
			pageSet(upLoadFileTemps, upLoadFileTempVo);
			list = (List<UpLoadFileTempVO>) beansCopy(upLoadFileTemps, UpLoadFileTempVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}
		
		return list;
	}
}
